<?php

namespace App\Models\Products;

use App\Services\Utils\ImageHelper;
use Illuminate\Database\Eloquent\Model;

class ProductImage extends Model
{
    protected $table = 'product_image';
    protected $guarded = [];

    /**
     * @return null|string
     */
    public function getImageAttribute()
    {
        $route = $this->attributes['image'];

        if ($route) {
            return ImageHelper::generateImagePath($route);
        } else {
            return null;
        }
    }
}
